#!/bin/bash
export LANG=zh_CN.UTF-8
PRESTO_HOME=/export/server/presto/bin/presto
MYSQL_HOME=/usr/bin/mysql
HIVE_HOME=/usr/bin/hive

start_time=`date +"%Y-%m-%d %H:%M:%S"`
echo "dws create table start ${start_time}" >> ./sqoop_liujie.log

${HIVE_HOME} -S -e "
create database if not exists edu_dws;

DROP TABLE IF EXISTS edu_dws.dws_stu_attendance_day_count;
create table if not exists edu_dws.dws_stu_attendance_day_count
(
    class_id                   INT comment '班级id',
    studying_student_count     INT comment '在读班级人数',
    morning_attendance_count   BIGINT comment '上午正常出勤人数',
    morning_leave_count        BIGINT comment '上午请假人数',
    morning_late_count         BIGINT comment '上午迟到人数',
    morning_truant_count       BIGINT comment '上午旷课人数',
    afternoon_attendance_count BIGINT comment '下午正常出勤人数',
    afternoon_leave_count      BIGINT comment '下午请假人数',
    afternoon_late_count       BIGINT comment '下午迟到人数',
    afternoon_truant_count     BIGINT comment '下午旷课人数',
    evening_attendance_count   BIGINT comment '晚上正常出勤人数',
    evening_leave_count        BIGINT comment '晚上请假人数',
    evening_late_count         BIGINT comment '晚上迟到人数',
    evening_truant_count       BIGINT comment '晚上旷课人数'
)partitioned by (studying_date string)
row format delimited fields terminated by '\t'
stored as orc tblproperties('orc.compress'='snappy');

"

start_time=`date +"%Y-%m-%d %H:%M:%S"`
echo "dws create table end ${start_time}" >> ./sqoop_liujie.log

